package com.bookcloud.java21.chapter2.算术运算符_基础2_10;

/** 2.10 算术运算符—基本 */
public class Lesson210 {
  public static void main(String[] args) {
    /*
    一、基本的算术
    1.加法：+
    2.减法：-
    3.乘法：*
    4.除法：/
    5.取余：%
     */
    // 1.加法
    int a = 10;
    int b = 20;
    int c = a + b;
    System.out.println("c:" + c);
    // 字符相加，相当于拼接
    String str1 = "hello";
    String str2 = " world ";
    int num = 199;
    String str3 = str1 + str2 + num;
    System.out.println(str3);
    // 2.减法
    int d = a - b;
    System.out.println("d:" + d);
    // 3.乘法
    int e = a * b;
    System.out.println("e:" + e);
    // 4.除法
    int num1 = 10;
    int num2 = 3;
    int f = num1 / num2;
    System.out.println("f:" + f);
    // 浮点数除法
    double num3 = 10.9;
    double num4 = 3.2;
    double h = num3 / num4;
    System.out.println("h:" + h);
    int i2 = (int) (num3 / num4);
    System.out.println("只取整数i2:" + i2);
    // 5.取余
    int g = num1 % num2;
    System.out.println("g:" + g);
  }
}
